package com.aircms.interceptor;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorCommon implements WebMvcConfigurer {

    @Bean
    InterceptorAdmin interceptorAdmin(){
        return new InterceptorAdmin();
    }


    @Bean
    InterceptorAuth interceptorAuth(){
        return new InterceptorAuth();
    }

    @Override
    public void addFormatters(FormatterRegistry registry) {

    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptorAdmin()).addPathPatterns("/auth/**");
        registry.addInterceptor(interceptorAuth()).addPathPatterns("/auth/**");
    }

    @Override
    public void addCorsMappings(CorsRegistry registry) {
    }
}
